/**
 * 
 */
package action;

/**
 * @author Administrator
 *
 */

import dao.*;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;


public class ProblemAction extends ActionSupport{
	private Integer problemId;
	private String problemPath;
	
	public void setProblemId(Integer problemId) {
		this.problemId = problemId;
	}
	public Integer getProblemId() {
		return problemId;
	}
	public void setProblemPath(String problemPath) {
		this.problemPath = problemPath;
	}
	public String getProblemPath() {
		return problemPath;
	}
	
	@Override
	public String execute() throws Exception{
		ActionContext ac = ActionContext.getContext();        
		HttpServletRequest request=(HttpServletRequest)ac.get(ServletActionContext.HTTP_REQUEST);
		ProblemDAO dao=new ProblemDAO();
		Problem p=dao.findById(problemId);
		if(p==null){
			addActionError("抱歉，你要的题目不存在......");
			return INPUT;
		}
		else{
			problemPath=p.getProblemPath();
			if(problemPath==null){
				addActionError("抱歉，你要的题目不存在......");
				return INPUT;
			}
			System.out.println("你选择的题目号是："+problemId);
			System.out.println("你选择的题路径是："+problemPath);
		    return SUCCESS;	
		}
		
		
	}


}